package cn.zxh.improvement.common.core.pipeline;

import cn.zxh.improvement.common.core.pipeline.context.EventContext;
import lombok.Getter;

/**
 * 管道
 *
 * @author zxh
 * @since 2023-6-7 16:12:23
 */
public class FilterChainPipeline<T extends EventContext, F extends EventFilter<T>> {
    private DefaultFilterChain<T> last;

    @Getter
    private String desc;

    public FilterChainPipeline() {
    }

    public DefaultFilterChain<T> getFilterChain() {
        return this.last;
    }

    public FilterChainPipeline<T, F> addFirst(F filter) {
        this.last = new DefaultFilterChain<T>(this.last, filter);
        return this;
    }

    public FilterChainPipeline<T, F> addFirst(String desc, F filter) {
        this.last = new DefaultFilterChain<T>(this.last, filter);
        this.desc = desc;
        return this;
    }
}
